﻿CREATE VIEW [dbo].[ASMS_V_MaterialWithStock]
	AS
select M.*, W.[Name] as WarehouseName, W.Id as WarehouseId, W.BusinessId as WarehouseBusinessId, W.StationId as WarehouseStationId,
	case when S.[Count] is null then 0 
		else S.[Count] end as [StockCount]
		from ASMS_Material as M
	inner join ASMS_Warehouse as W on 1=1
	left join ASMS_Stock as S on S.WarehouseId = W.Id and  S.MaterialId = M.Id
